package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.FlowFormEquipmentOffline;
import com.glsc.ngateway.common.base.domainmapper.FlowFormEquipmentOfflineMapper;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.equipment.domainDto.FlowFormEquipmentOfflineDto;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * FlowFormEquipmentOffline转换器
 * @author xuchang
 */
public class FlowFormEquipmentOfflineConverter extends AbstractFlowFormDataConverter {
    public static FlowFormEquipmentOfflineDto do2Dto(FlowFormEquipmentOffline offline) {
        if (Objects.isNull(offline)) {
            return null;
        }
        FlowFormEquipmentOfflineDto offlineDto = FlowFormEquipmentOfflineMapper.INSTANCE.domain2dto(offline);
        offlineDto.setAppendicesFileList(converter2FileList(offline.getAppendicesFileIdList()));
        return offlineDto;
    }

    public static List<FlowFormEquipmentOfflineDto> do2Dto(List<FlowFormEquipmentOffline> offlineList) {
        return CollectionUtils.isEmpty(offlineList) ? java.util.Collections.emptyList() : offlineList.stream().map(FlowFormEquipmentOfflineConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormEquipmentOffline dto2Do(FlowFormEquipmentOfflineDto offlineDto) {
        if (Objects.isNull(offlineDto)) {
            return null;
        }
        FlowFormEquipmentOffline offline = FlowFormEquipmentOfflineMapper.INSTANCE.dto2domain(offlineDto);
        offline.setAppendicesFileIdList(converter2FileIdList(offlineDto.getAppendicesFileList()));
        return offline;
    }

    public static List<FlowFormEquipmentOffline> dto2Do(List<FlowFormEquipmentOfflineDto> offlineDtoList) {
        return CollectionUtils.isEmpty(offlineDtoList) ? java.util.Collections.emptyList() : offlineDtoList.stream().map(FlowFormEquipmentOfflineConverter::dto2Do).collect(Collectors.toList());
    }

}
